Alphavantage provides a company overview API that returns a set of basic features for companies. Information on the API is provided in the link below. The scope of the below analysis is to inspect various features of S&P 500 companies so I can better integrate this information into my equity trends dashboard, which ultimately will inform future investments. Note that the API was called in a seperate batch job. Each API response was concatenated into a single Pandas DataFrame.
Based on this analysis - there are a few items I intend to explore further:
API documentation:
import requests
import pandas as pd
import pickle
import os
from pathlib import Path
import plotly.express as px
import plotly.graph_objects as go
import time
import numpy as np
import plotly.io as pio
from tqdm import tqdm
from datetime import datetime
from dateutil.relativedelta import relativedelta
import seaborn as sn
from sklearn.cluster import KMeans
import warnings
df_sp500 = pd.read_csv('sp500_tickers.csv')
tickers = df_sp500['Symbol'].values
df = pd.read_pickle('sp500_overview.pkl')
df.columns
Index(['Symbol', 'AssetType', 'Name', 'Description', 'CIK', 'Exchange',
'Currency', 'Country', 'Sector', 'Industry', 'Address', 'FiscalYearEnd',
'LatestQuarter', 'MarketCapitalization', 'EBITDA', 'PERatio',
'PEGRatio', 'BookValue', 'DividendPerShare', 'DividendYield', 'EPS',
'RevenuePerShareTTM', 'ProfitMargin', 'OperatingMarginTTM',
'ReturnOnAssetsTTM', 'ReturnOnEquityTTM', 'RevenueTTM',
'GrossProfitTTM', 'DilutedEPSTTM', 'QuarterlyEarningsGrowthYOY',
'QuarterlyRevenueGrowthYOY', 'AnalystTargetPrice', 'TrailingPE',
'ForwardPE', 'PriceToSalesRatioTTM', 'PriceToBookRatio', 'EVToRevenue',
'EVToEBITDA', 'Beta', '52WeekHigh', '52WeekLow', '50DayMovingAverage',
'200DayMovingAverage', 'SharesOutstanding', 'DividendDate',
'ExDividendDate'],
dtype='object')
df['PERatio'] = pd.to_numeric(df['PERatio'],errors='coerce')
df['PERatio'].describe()
count 485.000000 mean 27.920454 std 28.384796 min 2.395000 25% 13.620000 50% 20.960000 75% 31.750000 max 391.520000 Name: PERatio, dtype: float64
df['PERatio'].plot(kind='hist',figsize=(15,8))
<AxesSubplot:ylabel='Frequency'>
df['PERatio'].plot(kind='density',figsize=(15,8))
<AxesSubplot:ylabel='Density'>
df_pe_sector_pivot = df[['Sector','PERatio']]
df_pe_sector_pivot = df_pe_sector_pivot.reset_index()
df_pe_sector_pivot = df_pe_sector_pivot.pivot(columns='Sector',values='PERatio')
df_pe_sector_pivot.describe()
| Sector | ENERGY & TRANSPORTATION | FINANCE | LIFE SCIENCES | MANUFACTURING | REAL ESTATE & CONSTRUCTION | TECHNOLOGY | TRADE & SERVICES |
|---|---|---|---|---|---|---|---|
| count | 67.000000 | 66.000000 | 79.000000 | 89.000000 | 42.000000 | 71.000000 | 71.000000 |
| mean | 26.597896 | 14.070788 | 32.384114 | 25.023281 | 39.149452 | 36.166338 | 25.819507 |
| std | 24.018799 | 8.797264 | 26.283124 | 20.183683 | 32.729401 | 49.717695 | 14.459338 |
| min | 2.789000 | 4.392000 | 4.005000 | 2.708000 | 4.927000 | 5.110000 | 2.395000 |
| 25% | 14.990000 | 8.377500 | 16.710000 | 14.030000 | 14.800000 | 15.090000 | 17.455000 |
| 50% | 20.390000 | 10.420000 | 26.960000 | 20.360000 | 31.120000 | 24.230000 | 22.420000 |
| 75% | 28.585000 | 16.570000 | 36.840000 | 29.080000 | 50.052500 | 38.300000 | 29.930000 |
| max | 168.140000 | 43.860000 | 164.230000 | 141.010000 | 151.530000 | 391.520000 | 80.570000 |
df_pe_sector_pivot.plot(kind='density',figsize=(15,8))
<AxesSubplot:ylabel='Density'>
df_pe_sector_pivot.plot(kind='density',subplots=True,figsize=(15,20))
array([<AxesSubplot:ylabel='Density'>, <AxesSubplot:ylabel='Density'>,
<AxesSubplot:ylabel='Density'>, <AxesSubplot:ylabel='Density'>,
<AxesSubplot:ylabel='Density'>, <AxesSubplot:ylabel='Density'>,
<AxesSubplot:ylabel='Density'>], dtype=object)
df_pe_sector_pivot.plot(kind='box',figsize=(17,8))
<AxesSubplot:>
df_pe_sector_pivot.hist(cumulative=True,figsize=(20,15),grid=False)
array([[<AxesSubplot:title={'center':'ENERGY & TRANSPORTATION'}>,
<AxesSubplot:title={'center':'FINANCE'}>,
<AxesSubplot:title={'center':'LIFE SCIENCES'}>],
[<AxesSubplot:title={'center':'MANUFACTURING'}>,
<AxesSubplot:title={'center':'REAL ESTATE & CONSTRUCTION'}>,
<AxesSubplot:title={'center':'TECHNOLOGY'}>],
[<AxesSubplot:title={'center':'TRADE & SERVICES'}>,
<AxesSubplot:>, <AxesSubplot:>]], dtype=object)
df.columns
Index(['Symbol', 'AssetType', 'Name', 'Description', 'CIK', 'Exchange',
'Currency', 'Country', 'Sector', 'Industry', 'Address', 'FiscalYearEnd',
'LatestQuarter', 'MarketCapitalization', 'EBITDA', 'PERatio',
'PEGRatio', 'BookValue', 'DividendPerShare', 'DividendYield', 'EPS',
'RevenuePerShareTTM', 'ProfitMargin', 'OperatingMarginTTM',
'ReturnOnAssetsTTM', 'ReturnOnEquityTTM', 'RevenueTTM',
'GrossProfitTTM', 'DilutedEPSTTM', 'QuarterlyEarningsGrowthYOY',
'QuarterlyRevenueGrowthYOY', 'AnalystTargetPrice', 'TrailingPE',
'ForwardPE', 'PriceToSalesRatioTTM', 'PriceToBookRatio', 'EVToRevenue',
'EVToEBITDA', 'Beta', '52WeekHigh', '52WeekLow', '50DayMovingAverage',
'200DayMovingAverage', 'SharesOutstanding', 'DividendDate',
'ExDividendDate'],
dtype='object')
df_numeric = df[['MarketCapitalization', 'EBITDA', 'PERatio',
'PEGRatio', 'BookValue', 'DividendPerShare', 'DividendYield', 'EPS',
'RevenuePerShareTTM', 'ProfitMargin', 'OperatingMarginTTM',
'ReturnOnAssetsTTM', 'ReturnOnEquityTTM', 'RevenueTTM',
'GrossProfitTTM', 'DilutedEPSTTM', 'QuarterlyEarningsGrowthYOY',
'QuarterlyRevenueGrowthYOY', 'AnalystTargetPrice', 'TrailingPE',
'ForwardPE', 'PriceToSalesRatioTTM', 'PriceToBookRatio', 'EVToRevenue',
'EVToEBITDA', 'Beta', '52WeekHigh', '52WeekLow', '50DayMovingAverage',
'200DayMovingAverage', 'SharesOutstanding']]
cols = list(df_numeric.columns)
df_numeric = df_numeric[cols].apply(pd.to_numeric,errors='coerce')
Likely not accurate due to outliers or non-linear relationships, but something interesting may show up.
corr_matrix = df_numeric.corr()
corr_matrix[(corr_matrix[cols]>.5) | (corr_matrix[cols]<-.5) ]
| MarketCapitalization | EBITDA | PERatio | PEGRatio | BookValue | DividendPerShare | DividendYield | EPS | RevenuePerShareTTM | ProfitMargin | ... | PriceToSalesRatioTTM | PriceToBookRatio | EVToRevenue | EVToEBITDA | Beta | 52WeekHigh | 52WeekLow | 50DayMovingAverage | 200DayMovingAverage | SharesOutstanding | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MarketCapitalization | 1.000000 | 0.909372 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.638433 |
| EBITDA | 0.909372 | 1.000000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.737887 |
| PERatio | NaN | NaN | 1.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| PEGRatio | NaN | NaN | NaN | 1.0 | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| BookValue | NaN | NaN | NaN | NaN | 1.000000 | NaN | NaN | 0.765432 | 0.576182 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.689648 | 0.713928 | 0.685486 | 0.696903 | NaN |
| DividendPerShare | NaN | NaN | NaN | NaN | NaN | 1.0 | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| DividendYield | NaN | NaN | NaN | NaN | NaN | NaN | 1.0 | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| EPS | NaN | NaN | NaN | NaN | 0.765432 | NaN | NaN | 1.000000 | 0.728651 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.804915 | 0.836654 | 0.807726 | 0.806741 | NaN |
| RevenuePerShareTTM | NaN | NaN | NaN | NaN | 0.576182 | NaN | NaN | 0.728651 | 1.000000 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.651115 | 0.663083 | 0.657056 | 0.647448 | NaN |
| ProfitMargin | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 1.000000 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| OperatingMarginTTM | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.759501 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ReturnOnAssetsTTM | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ReturnOnEquityTTM | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| RevenueTTM | 0.625652 | 0.711563 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| GrossProfitTTM | 0.785417 | 0.914537 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.632938 |
| DilutedEPSTTM | NaN | NaN | NaN | NaN | 0.765432 | NaN | NaN | 1.000000 | 0.728651 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.804915 | 0.836654 | 0.807726 | 0.806741 | NaN |
| QuarterlyEarningsGrowthYOY | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| QuarterlyRevenueGrowthYOY | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| AnalystTargetPrice | NaN | NaN | NaN | NaN | 0.704181 | NaN | NaN | 0.809716 | 0.656374 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.993690 | 0.993783 | 0.997128 | 0.997364 | NaN |
| TrailingPE | NaN | NaN | 1.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ForwardPE | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| PriceToSalesRatioTTM | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 1.000000 | NaN | 0.941118 | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| PriceToBookRatio | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | 1.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| EVToRevenue | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | 0.941118 | NaN | 1.000000 | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| EVToEBITDA | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | 1.0 | NaN | NaN | NaN | NaN | NaN | NaN |
| Beta | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | 1.0 | NaN | NaN | NaN | NaN | NaN |
| 52WeekHigh | NaN | NaN | NaN | NaN | 0.689648 | NaN | NaN | 0.804915 | 0.651115 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 1.000000 | 0.987791 | 0.992125 | 0.998022 | NaN |
| 52WeekLow | NaN | NaN | NaN | NaN | 0.713928 | NaN | NaN | 0.836654 | 0.663083 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.987791 | 1.000000 | 0.993481 | 0.993397 | NaN |
| 50DayMovingAverage | NaN | NaN | NaN | NaN | 0.685486 | NaN | NaN | 0.807726 | 0.657056 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.992125 | 0.993481 | 1.000000 | 0.995962 | NaN |
| 200DayMovingAverage | NaN | NaN | NaN | NaN | 0.696903 | NaN | NaN | 0.806741 | 0.647448 | NaN | ... | NaN | NaN | NaN | NaN | NaN | 0.998022 | 0.993397 | 0.995962 | 1.000000 | NaN |
| SharesOutstanding | 0.638433 | 0.737887 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 1.000000 |
31 rows × 31 columns
Mitgate the effects of outliers and skewed distributions from pearsons correlation used above.
Interesting correlations from both the Pearson and Spearman's correlation method are noted below:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
spearman_corr_matrix = df_numeric.corr(method='spearman')
spearman_corr_matrix = spearman_corr_matrix[(spearman_corr_matrix[cols]>.5) | (spearman_corr_matrix[cols]<-.5) ]
spearman_corr_matrix = spearman_corr_matrix[(spearman_corr_matrix[cols]<1) ]
# matrix is large, but via inspection there are some correlations not worth keeping
spearman_corr_matrix = spearman_corr_matrix.drop(['DividendPerShare','DividendYield','PEGRatio','PERatio','Beta','QuarterlyEarningsGrowthYOY','QuarterlyRevenueGrowthYOY'],axis=1)
spearman_corr_matrix = spearman_corr_matrix.dropna(how='all')
spearman_corr_matrix.iloc[:,0:8]
| MarketCapitalization | EBITDA | BookValue | EPS | RevenuePerShareTTM | ProfitMargin | OperatingMarginTTM | ReturnOnAssetsTTM | |
|---|---|---|---|---|---|---|---|---|
| MarketCapitalization | NaN | 0.763368 | NaN | NaN | NaN | NaN | NaN | NaN |
| EBITDA | 0.763368 | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| PERatio | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| BookValue | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| EPS | NaN | NaN | NaN | NaN | 0.651086 | NaN | NaN | NaN |
| RevenuePerShareTTM | NaN | NaN | NaN | 0.651086 | NaN | NaN | NaN | NaN |
| ProfitMargin | NaN | NaN | NaN | NaN | NaN | NaN | 0.878339 | NaN |
| OperatingMarginTTM | NaN | NaN | NaN | NaN | NaN | 0.878339 | NaN | NaN |
| ReturnOnAssetsTTM | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ReturnOnEquityTTM | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.653680 |
| RevenueTTM | 0.620930 | 0.833959 | NaN | NaN | NaN | NaN | NaN | NaN |
| GrossProfitTTM | 0.742689 | 0.893099 | NaN | NaN | NaN | NaN | NaN | NaN |
| DilutedEPSTTM | NaN | NaN | NaN | NaN | 0.651086 | NaN | NaN | NaN |
| AnalystTargetPrice | NaN | NaN | NaN | 0.652923 | NaN | NaN | NaN | NaN |
| TrailingPE | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| ForwardPE | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| PriceToSalesRatioTTM | NaN | NaN | NaN | NaN | -0.542146 | 0.584166 | 0.601093 | NaN |
| PriceToBookRatio | NaN | NaN | -0.507461 | NaN | NaN | NaN | NaN | 0.582311 |
| EVToRevenue | NaN | NaN | NaN | NaN | -0.604501 | 0.565784 | 0.624006 | NaN |
| EVToEBITDA | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 52WeekHigh | NaN | NaN | NaN | 0.642516 | NaN | NaN | NaN | NaN |
| 52WeekLow | NaN | NaN | NaN | 0.652603 | NaN | NaN | NaN | NaN |
| 50DayMovingAverage | NaN | NaN | NaN | 0.661389 | NaN | NaN | NaN | NaN |
| 200DayMovingAverage | NaN | NaN | NaN | 0.648121 | NaN | NaN | NaN | NaN |
| SharesOutstanding | 0.614863 | 0.680360 | NaN | NaN | NaN | NaN | NaN | NaN |
spearman_corr_matrix.iloc[:,9:15]
| RevenueTTM | GrossProfitTTM | DilutedEPSTTM | AnalystTargetPrice | TrailingPE | ForwardPE | |
|---|---|---|---|---|---|---|
| MarketCapitalization | 0.620930 | 0.742689 | NaN | NaN | NaN | NaN |
| EBITDA | 0.833959 | 0.893099 | NaN | NaN | NaN | NaN |
| PERatio | NaN | NaN | NaN | NaN | NaN | 0.790322 |
| BookValue | NaN | NaN | NaN | NaN | NaN | NaN |
| EPS | NaN | NaN | NaN | 0.652923 | NaN | NaN |
| RevenuePerShareTTM | NaN | NaN | 0.651086 | NaN | NaN | NaN |
| ProfitMargin | NaN | NaN | NaN | NaN | NaN | NaN |
| OperatingMarginTTM | NaN | NaN | NaN | NaN | NaN | NaN |
| ReturnOnAssetsTTM | NaN | NaN | NaN | NaN | NaN | NaN |
| ReturnOnEquityTTM | NaN | NaN | NaN | NaN | NaN | NaN |
| RevenueTTM | NaN | 0.861770 | NaN | NaN | NaN | NaN |
| GrossProfitTTM | 0.861770 | NaN | NaN | NaN | NaN | NaN |
| DilutedEPSTTM | NaN | NaN | NaN | 0.652923 | NaN | NaN |
| AnalystTargetPrice | NaN | NaN | 0.652923 | NaN | NaN | NaN |
| TrailingPE | NaN | NaN | NaN | NaN | NaN | 0.790322 |
| ForwardPE | NaN | NaN | NaN | NaN | 0.790322 | NaN |
| PriceToSalesRatioTTM | -0.548165 | NaN | NaN | NaN | 0.599497 | 0.676091 |
| PriceToBookRatio | NaN | NaN | NaN | NaN | NaN | NaN |
| EVToRevenue | -0.559808 | NaN | NaN | NaN | 0.613611 | 0.701722 |
| EVToEBITDA | NaN | NaN | NaN | NaN | 0.835728 | 0.748687 |
| 52WeekHigh | NaN | NaN | 0.642516 | 0.988921 | NaN | NaN |
| 52WeekLow | NaN | NaN | 0.652603 | 0.982544 | NaN | NaN |
| 50DayMovingAverage | NaN | NaN | 0.661389 | 0.992789 | NaN | NaN |
| 200DayMovingAverage | NaN | NaN | 0.648121 | 0.991170 | NaN | NaN |
| SharesOutstanding | 0.589325 | 0.647117 | NaN | NaN | NaN | NaN |
spearman_corr_matrix.iloc[:,15:20]
| PriceToSalesRatioTTM | PriceToBookRatio | EVToRevenue | EVToEBITDA | 52WeekHigh | |
|---|---|---|---|---|---|
| MarketCapitalization | NaN | NaN | NaN | NaN | NaN |
| EBITDA | NaN | NaN | NaN | NaN | NaN |
| PERatio | 0.599497 | NaN | 0.613611 | 0.835728 | NaN |
| BookValue | NaN | -0.507461 | NaN | NaN | NaN |
| EPS | NaN | NaN | NaN | NaN | 0.642516 |
| RevenuePerShareTTM | -0.542146 | NaN | -0.604501 | NaN | NaN |
| ProfitMargin | 0.584166 | NaN | 0.565784 | NaN | NaN |
| OperatingMarginTTM | 0.601093 | NaN | 0.624006 | NaN | NaN |
| ReturnOnAssetsTTM | NaN | 0.582311 | NaN | NaN | NaN |
| ReturnOnEquityTTM | NaN | 0.599179 | NaN | NaN | NaN |
| RevenueTTM | -0.548165 | NaN | -0.559808 | NaN | NaN |
| GrossProfitTTM | NaN | NaN | NaN | NaN | NaN |
| DilutedEPSTTM | NaN | NaN | NaN | NaN | 0.642516 |
| AnalystTargetPrice | NaN | NaN | NaN | NaN | 0.988921 |
| TrailingPE | 0.599497 | NaN | 0.613611 | 0.835728 | NaN |
| ForwardPE | 0.676091 | NaN | 0.701722 | 0.748687 | NaN |
| PriceToSalesRatioTTM | NaN | NaN | 0.964940 | 0.649795 | NaN |
| PriceToBookRatio | NaN | NaN | NaN | NaN | NaN |
| EVToRevenue | 0.964940 | NaN | NaN | 0.637234 | NaN |
| EVToEBITDA | 0.649795 | NaN | 0.637234 | NaN | NaN |
| 52WeekHigh | NaN | NaN | NaN | NaN | NaN |
| 52WeekLow | NaN | NaN | NaN | NaN | 0.974230 |
| 50DayMovingAverage | NaN | NaN | NaN | NaN | 0.982349 |
| 200DayMovingAverage | NaN | NaN | NaN | NaN | 0.995073 |
| SharesOutstanding | NaN | NaN | NaN | NaN | -0.513378 |
"Book value is equal to the cost of carrying an asset on a company's balance sheet, and firms calculate it netting the asset against its accumulated depreciation. As a result, book value can also be thought of as the net asset value (NAV) of a company, calculated as its total assets minus intangible assets (patents, goodwill) and liabilities. For the initial outlay of an investment, book value may be net or gross of expenses such as trading costs, sales taxes, service charges, and so on."
"As the accounting value of a firm, book value has two main uses:
1) It serves as the total value of the company's assets that shareholders would theoretically receive if a company was liquidated.
2) When compared to the company's market value, book value can indicate whether a stock is under- or overpriced."
Quoted from https://www.investopedia.com/terms/b/bookvalue.asp
From the charts below, it appears that outliers were the main contributors to a positive correlation, which makes sense that spearmans didn't catch the correlation. This could something to watch - identify companies with outlier book values.
df_numeric['BookValue'].plot(kind='hist',figsize=(10,5))
<AxesSubplot:ylabel='Frequency'>
df_numeric['BookValue'].describe()
count 499.000000 mean 39.476539 std 57.405192 min -71.780000 25% 13.835000 50% 27.050000 75% 46.490000 max 822.240000 Name: BookValue, dtype: float64
df_numeric['BookValue'].plot(kind='box',figsize=(17,8))
<AxesSubplot:>
px.scatter(df_numeric,x=df_numeric['BookValue'],y=df_numeric['EPS'],trendline='ols')
book_value_below_q3 = df_numeric[(df_numeric['BookValue']<45) & (df_numeric['BookValue']>13)]
px.scatter(book_value_below_q3,x='BookValue',y='EPS',trendline='ols')
book_value_below_q3 = df_numeric[(df_numeric['BookValue']<45) & (df_numeric['BookValue']>13)]
px.scatter(book_value_below_q3,x='BookValue',y='EPS',trendline='lowess')
book_value_above_q3 = df_numeric[(df_numeric['BookValue']>45)]
px.scatter(book_value_above_q3,x='BookValue',y='EPS',trendline='ols')
"The EV/EBITDA ratio is a popular metric used as a valuation tool to compare the value of a company, debt included, to the company’s cash earnings less non-cash expenses. It's ideal for analysts and investors looking to compare companies within the same industry.
The enterprise-value-to-EBITDA ratio is calculated by dividing EV by EBITDA or earnings before interest, taxes, depreciation, and amortization. Typically, EV/EBITDA values below 10 are seen as healthy. However, the comparison of relative values among companies within the same industry is the best way for investors to determine companies with the healthiest EV/EBITDA within a specific sector.
Benefits of EV/EBITDA Analysis
Just like the P/E ratio (price-to-earnings), the lower the EV/EBITDA, the cheaper the valuation for a company. Although the P/E ratio is typically used as the go-to-valuation tool, there are benefits to using the P/E ratio along with the EV/EBITDA. For example, many investors look for companies that have both low valuations using P/E and EV/EBITDA and solid dividend growth."
Quoted from https://www.investopedia.com/ask/answers/072715/what-considered-healthy-evebitda.asp
Investopedia indicates there is a correlation between EV/EBITDA and PE Ratio. This is a good example of statical analysis leading to a new metric which we can start evaluating. There is an obvious correlation, and if I'm using PE I should include this in my analysis of individual equities.
df_numeric['EVToEBITDA'].plot(kind='hist',figsize=(10,5))
<AxesSubplot:ylabel='Frequency'>
df_numeric['EVToEBITDA'].describe()
count 452.000000 mean 20.136261 std 44.790984 min 2.639000 25% 10.117500 50% 14.445000 75% 19.607500 max 764.200000 Name: EVToEBITDA, dtype: float64
px.scatter(df_numeric,x='EVToEBITDA',y='PERatio',trendline='ols')
evtoebitda_df = df_numeric[df_numeric['EVToEBITDA'] < 100]
px.scatter(evtoebitda_df,x='EVToEBITDA',y='PERatio',trendline='ols')
"The enterprise value-to-revenue multiple (EV/R) is a measure of the value of a stock that compares a company's enterprise value to its revenue. EV/R is one of several fundamental indicators that investors use to determine whether a stock is priced fairly. The EV/R multiple is also often used to determine a company's valuation in the case of a potential acquisition. It’s also called the enterprise value-to-sales multiple."
Quoted from Investopedia: https://www.investopedia.com/terms/e/ev-revenue-multiple.asp
"This value measures the percent of revenues remaining after paying all operating expenses. It is calculated as the trailing 12 months Operating Income divided by the trailing 12 months Total Revenue, multiplied by 100. Operating Income is defined as Total Revenue minus Total Operating Expenses."
Quoted from https://plexus.gcs-web.com/definition/operating-margin-ttm
Based on the descriptions above, it is interesting there is a correlation here, since operating margins can fluctuate and on a % basis wouldn't seem to be connected to revenue.
df_numeric['EVToRevenue'].plot(kind='hist',figsize=(10,5))
<AxesSubplot:ylabel='Frequency'>
df_numeric['EVToRevenue'].describe()
count 473.000000 mean 4.695545 std 4.066161 min 0.104000 25% 1.866000 50% 3.551000 75% 5.720000 max 23.270000 Name: EVToRevenue, dtype: float64
df_numeric['OperatingMarginTTM'].plot(kind='hist',figsize=(10,5))
<AxesSubplot:ylabel='Frequency'>
df_numeric['OperatingMarginTTM'].describe()
count 502.000000 mean 0.201545 std 0.207723 min -2.288000 25% 0.125000 50% 0.190000 75% 0.279750 max 0.719000 Name: OperatingMarginTTM, dtype: float64
px.scatter(df_numeric,x='EVToRevenue',y='OperatingMarginTTM',trendline='ols')
operating_marginTTM_df = df_numeric[df_numeric['OperatingMarginTTM'] > -.05]
px.scatter(operating_marginTTM_df,x='EVToRevenue',y='OperatingMarginTTM',trendline='ols')
px.scatter(operating_marginTTM_df,x='EVToRevenue',y='OperatingMarginTTM',trendline='lowess')